#include "PPT3DSpace.h"
#include "Fysics/Object/Item.h"
#include "Fysics/System/ResourceManager.h"
#include "Fysics/Event/WindowEvent.h"
#include "Fysics/Input/FysicsKeyCodes.h"
#include "Fysics/Application/Application.h"

PPT3DSpace::PPT3DSpace()
	: Space("PPT3d")
{
}

void PPT3DSpace::OnStart()
{
	Fysics::Item* item = new Fysics::Item("nanosuit", "nanosuit", { 0, 0, -10 });
	Fysics::ResourceManager* rm = Fysics::ResourceManager::GetInstance();
	rm->LoadMeshFromFile("res/mesh/nanosuit/nanosuit.obj");
	item->SetMeshes(rm->GetMeshes("res/mesh/nanosuit/nanosuit.obj"));

	AddObject(item, Fysics::ObjectDisplayMode::SCENE);

	RegisterEvent(Fysics::EventType::KeyPressed, [this](Fysics::Event& e) {
		Fysics::WindowKeyPressedEvent event = (Fysics::WindowKeyPressedEvent&) e;
		switch (event.GetKeyCode())
		{
		case FAR_KEY_Y:
			GetParent()->SwitchSpace("main");
			break;
		default:
			break;
		}
	});
}
